package com.lzw.kotdemo.bean

import android.util.Log
import com.google.gson.Gson
import java.util.*


/**KotlinDemo
 * Created by lzw on 2019/1/2. 11:53:09
 * 邮箱：632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
data class ForecastRquest(val zipCode:String){

    companion object {
        private val APP_ID = "15646a06818f61f7b8d7823ca833e1ce"
        private val URL = "http://api.openweathermap.org/data/2.5/" +
                "forecast/daily?mode=json&units=metric&cnt=7"
        private val COMPLETEL_URL = "$URL&APPID=$APP_ID&q="
    }

    fun execute():ForecastResult{
        val  forecastJsonStr = java.net.URL(COMPLETEL_URL + zipCode).readText()
        Log.i("返回的数据",forecastJsonStr)
        return Gson().fromJson(forecastJsonStr,ForecastResult::class.java)
    }
}